'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  // 在执行数据库升级时调用的函数，创建 profit 表
  async up(queryInterface, Sequelize) {
    const { DECIMAL, INTEGER, STRING, DATE } = Sequelize;
    await queryInterface.createTable('bills', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      balance: {
        type: DECIMAL(10, 2),
        defaultValue: 0.0,
        comment: '账户余额(元)',
      },
      price: {
        type: STRING,
        comment: '金额变动',
      },
      user_id: {
        type: INTEGER,
        allowNull: false,
        comment: '用户id',
      },
      bz: {
        type: STRING,
        comment: '备注',
      },
      created_at: DATE,
      updated_at: DATE,
    });
  },
  // 在执行数据库降级时调用的函数，删除 users 表
  async down(queryInterface) {
    await queryInterface.dropTable('bills');
  },
};
